package com.ruoyi.web.controller.yijing;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.yijing.domain.YjGuaYao;
import com.ruoyi.yijing.service.IYjGuaiYaoService;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 卦和爻的关系Controller
 * 
 * @author ruoyi
 * @date 2024-01-22
 */
@RestController
@RequestMapping("/yijing/guai/yao")
public class YjGuaiYaoController extends BaseController
{
    @Autowired
    private IYjGuaiYaoService yjGuaiYaoService;

    /**
     * 查询卦和爻的关系列表
     */
    //@PreAuthorize("@ss.hasPermi('yijing:yao:list')")
    @GetMapping("/list")
    public TableDataInfo list(YjGuaYao yjGuaiYao)
    {
        if (yjGuaiYao.getGuaId() == null){
            yjGuaiYao.setGuaId(0);
        }
        startPage();
        List<YjGuaYao> list = yjGuaiYaoService.selectYjGuaiYaoList(yjGuaiYao);
        return getDataTable(list);
    }

    /**
     * 获取卦和爻的关系详细信息
     */
    //@PreAuthorize("@ss.hasPermi('yijing:yao:query')")
    @GetMapping(value = "/{yaoId}")
    public AjaxResult getInfo(@PathVariable("yaoId") Long yaoId)
    {
        return success(yjGuaiYaoService.selectYjGuaiYaoByYaoId(yaoId));
    }

    /**
     * 新增卦和爻的关系
     */
    //@PreAuthorize("@ss.hasPermi('yijing:yao:add')")
    @Log(title = "添加卦和爻的关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YjGuaYao yjGuaiYao)
    {
        return toAjax(yjGuaiYaoService.insertYjGuaiYao(yjGuaiYao));
    }

    /**
     * 修改卦和爻的关系
     */
    //@PreAuthorize("@ss.hasPermi('yijing:yao:edit')")
    @Log(title = "修改卦和爻的关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YjGuaYao yjGuaiYao)
    {
        return toAjax(yjGuaiYaoService.updateYjGuaiYao(yjGuaiYao));
    }

    /**
     * 删除卦和爻的关系
     */
    //@PreAuthorize("@ss.hasPermi('yijing:yao:remove')")
    @Log(title = "删除卦和爻的关系", businessType = BusinessType.DELETE)
	@DeleteMapping("/{yaoId}")
    public AjaxResult remove(@PathVariable Long yaoId)
    {
        return toAjax(yjGuaiYaoService.deleteYjGuaiYaoByYaoId(yaoId));
    }
}
